package com.gxy.learn.design.model.behaviour.command;

import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * @description: 具体的命令类
 * @author: gaoxueyong
 * @Date: 2022/11/8 14:41
 */
@Slf4j
public class OrderCommand implements Command{

//    持有接受者对象
    private SeniorChef receive;
//    持有订单对象
    private Order order;

    public OrderCommand(SeniorChef receive, Order order) {
        this.receive = receive;
        this.order = order;
    }

    /**
     * 命令执行方法
     *
     * @return void
     * @Author gaoxueyong
     * @Date 2:41 下午 2022/11/8
     * @Param []
     **/
    @Override
    public void execute() {
        log.info("{}桌的订单：",order.getDiningTable());
        Map<String, Integer> foodDir = order.getFoodDir();
        for(Map.Entry<String,Integer> entry:foodDir.entrySet()){
            receive.makeFood(entry.getKey(),entry.getValue());
        }
        log.info("{}桌的饭已烹饪完毕！",order.getDiningTable());
    }
}
